<!--

    Copyright © 2016-2025 The Thingsboard Authors

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

        http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.

-->
<mat-toolbar class="min-w-0" color="primary">
  <h2>{{ 'api-key.generated-api-key-title' | translate }}</h2>
  <span class="flex-1"></span>
  <button mat-icon-button
          (click)="close()"
          type="button">
    <mat-icon class="material-icons">close</mat-icon>
  </button>
</mat-toolbar>
<div mat-dialog-content>
  <div class="tb-form-panel no-padding no-border">
    <div class="tb-no-data-text font-normal" translate>api-key.generated-api-key-copy</div>
    <div class="tb-form-panel no-padding no-border">
      <tb-markdown usePlainMarkdown containerClass="tb-command-code"
                   [data]='createMarkDownCommand(data.apiKey.value)'></tb-markdown>
    </div>
    <div class="tb-form-panel no-padding no-border tb-tab-body">
      <div class="tb-no-data-text font-normal" translate>api-key.generated-api-key-command</div>
      <mat-tab-group [selectedIndex]="selectedTab">
        <mat-tab>
          <ng-template mat-tab-label>
            <mat-icon class="tabs-icon" svgIcon="windows"></mat-icon>
            Windows
          </ng-template>
          <ng-template matTabContent>
            <div class="tb-form-panel no-padding no-border tb-tab-body">
              <div class="tb-form-panel stroked">
                <div class="tb-form-panel-title" translate>device.connectivity.install-necessary-client-tools</div>
                <div class="tb-install-instruction-text" translate>device.connectivity.install-curl-windows</div>
              </div>
              <ng-container *ngTemplateOutlet="executeCommand"></ng-container>
            </div>
          </ng-template>
        </mat-tab>
        <mat-tab>
          <ng-template mat-tab-label>
            <mat-icon class="tabs-icon" svgIcon="macos"></mat-icon>
            MacOS
          </ng-template>
          <ng-template matTabContent>
            <div class="tb-form-panel no-padding no-border tb-tab-body">
              <div class="tb-form-panel stroked">
                <div class="tb-form-panel-title" translate>device.connectivity.install-necessary-client-tools</div>
                <div class="tb-install-instruction-text" translate>device.connectivity.install-curl-macos</div>
              </div>
              <ng-container *ngTemplateOutlet="executeCommand"></ng-container>
            </div>
          </ng-template>
        </mat-tab>
        <mat-tab>
          <ng-template mat-tab-label>
            <mat-icon class="tabs-icon" svgIcon="linux"></mat-icon>
            Linux
          </ng-template>
          <ng-template matTabContent>
            <div class="tb-form-panel no-padding no-border tb-tab-body">
              <div class="tb-form-panel stroked">
                <div class="tb-form-panel-title" translate>device.connectivity.install-necessary-client-tools</div>
                <tb-markdown usePlainMarkdown containerClass="tb-command-code"
                             [data]='createMarkDownCommand("sudo apt-get install curl")'></tb-markdown>
              </div>
              <ng-container *ngTemplateOutlet="executeCommand"></ng-container>
            </div>
          </ng-template>
        </mat-tab>
      </mat-tab-group>
    </div>
  </div>
</div>
<div mat-dialog-actions class="justify-end">
  <button mat-raised-button color="primary"
          type="button"
          [disabled]="(isLoading$ | async)"
          (click)="close()">
    {{ 'action.close' | translate }}
  </button>
</div>

<ng-template #executeCommand>
  <div class="tb-form-panel stroked">
    <div class="tb-form-panel-title" translate>device.connectivity.execute-following-command</div>
    <tb-markdown usePlainMarkdown containerClass="tb-command-code" [data]='createMarkDownCommand(apiKeyCommand)'></tb-markdown>
  </div>
</ng-template>
